﻿using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _01coreLogger
{
    public class sqlconnection : ISqlConnection
    {

        private ILogger<sqlconnection> logger;

        public sqlconnection(ILoggerFactory factory )
        {
            this.logger = factory.CreateLogger<sqlconnection>();
        }

        public void Connectionstring()
        {
 
            logger.LogInformation("开始连接数据库");
            logger.LogWarning("第一次连接失败");
            logger.LogWarning("第二次连接失败");
            logger.LogWarning("第三次连接失败");
            logger.LogError("数据库连接失败");
            File.WriteAllLines("E:\\c#体系课\\05三层项目-餐饮管理系统\\code\\餐饮管理系统\\01coreLogger\\bin\\Debug\\net7.0\\logger\\logger.txt", new string[] { "开始连接数据库", "第一次连接失败", "第二次连接失败", "第三次连接失败", "数据库连接失败" });
        }
    }
}
